package chances.wechat.repository;

import java.util.HashMap;
import java.util.Map;

import org.springframework.stereotype.Repository;

import chances.wechat.entity.UserMedia;

@Repository
public class UserMediaRepository extends BaseRepository {

	public void insertMedia(UserMedia media) {
		this.sqlSessionTemplateMaster.insert(this.getNamespaceM("insertMedia"), media);
	}

	/*public List<UserMedia> getStbUserMediaByOpenId(String[] ids) {
		String name = this.getName("getStbMediaByOpenIds");
		return sqlSessionTemplate.selectList(name, ids);
	}*/

	public void updateMedia(UserMedia media) {
		String name = this.getNamespaceM("updateMedia");
		this.sqlSessionTemplateMaster.update(name, media);
	}

	public UserMedia getMediaByMediaId(String mediaId) {
		return this.getOne("getMediaByMediaId", mediaId);
	}

	/*public List<UserMedia> listMediaByTime(Date date) {
		return super.sqlSessionTemplate.selectList("listMediaByCreateTime", date);
	}*/

	public void delMediaByMediaIds(String[] mediaIds, Integer status) {
		String name = this.getNamespaceM("delMediaByMediaIds");
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("status", status);
		params.put("mediaIds", mediaIds);
		this.sqlSessionTemplateMaster.delete(name, params);
	}

}
